package cn.fotoit.product.app1.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import org.hibernate.annotations.*;

import javax.persistence.*;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;

@Entity
@Table(name = "menu")
@Data
@SQLDelete(sql = "update menu set deleted = true where id = ?")
@Where(clause = "deleted = false")
public class Menu implements Serializable {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;

    @Column(nullable = false)
    private String name;

    private String url;

    @CreationTimestamp
    @Column(updatable = false)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    @UpdateTimestamp
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;

    @Column(nullable = false)
    private Integer orders;

    @Column(nullable = false)
    private Boolean isOnline;

    @Column(nullable = false)
    @ColumnDefault(value = "false")
    private Boolean isHot;

    @Column(nullable = false)
    @ColumnDefault(value = "true")
    private Boolean isMustLogin;


    @ColumnDefault(value = "false")
    private Boolean deleted = false;

    @JsonIgnore
    private byte[] imgByte;

    @Column(nullable = false)
    private Integer groupId;

}